<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix='sec' uri='http://www.springframework.org/security/tags'%>
<head>
	<script type="text/javascript" src="scripts/boot.js"></script>
</head>

<body>
	<form id="form1" method="post">
		<p style="margin-left: 20px;">
			 <label>计算开始时间：</label>
			 <input name="startTime"  class="mini-datepicker" required="true" style="width: 130px" 
			 	showClearButton="true" allowInput="false"/>
			<label>计算结束时间：</label>
			<input name="endTime" class="mini-datepicker" ondrawdate="onDrawDate" required="true" style="width: 130px" 
				showClearButton="true" allowInput="false"/>
		</p>
	</form>
    <p style="margin-left: 160px;margin-top: 160px;">
    	<a class="mini-button" onclick="onOk" style="width:60px;margin-right:50px;">确定</a>
    	<a class="mini-button" onclick="onCancel" style="width:60px;">取消</a>
    </p>
</body>

<script type="text/javascript">
	mini.parse();
	var form = new mini.Form("form1");
	
	function SaveData() {
        var o = form.getData(true);            

        form.validate();
        if (form.isValid() == false) return;
        var startTime = mini.getbyName("startTime").getValue();
        var endTime = mini.getbyName("endTime").getValue();
        if(startTime >= endTime) {
        	mini.alert("开始时间不能大于结束时间");
        } else {
	        $.ajax({
	            url: "staff_salary_save.do",
				type: 'post',
				dataType: 'json',
	            data: o,
	            cache: false,
	            success: function (text) {
	            	if(text.success){
		            	window.CloseOwnerWindow("succ");
		            }else{
		            	mini.alert("数据错误，请重新添加");
		            }
	            },
	            error: function (jqXHR, textStatus, errorThrown) {
	                alert(jqXHR.responseText);
	                CloseWindow();
	            }
	        });
        }
    }
	
	function onOk(e) {
        SaveData();
    }
	
	function SetData(data){
	     data = mini.clone(data);
	}
	
	function CloseWindow(action) {            
        if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
        else window.close();            
    }
	
	function onCancel(e) {
        CloseWindow("cancel");
    }

	function onDrawDate(e) {
        var date = e.date;
        var d = new Date();
        if (date.getTime() > d.getTime()) {
            e.allowSelect = false;
        }
    }
</script>